<template>
  <div class="count-down">
    页面切换倒计时 <span>{{ endTime }}</span> 秒
  </div>
</template>

<script>
import { commonGetJumpTimes } from "@/utils/common";
export default {
  components: {},
  props: {
    // 倒计时截止时间
    goPage: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      endTime: null, //倒计时 秒数
      vGoPage: this.goPage,
    };
  },
  watch: {
    // vGoPage: {
    //   handler(newValue, oldValue) {
    //     // console.log("999999变化了", newValue);
    //     this.endTime = commonGetJumpTimes();
    //     console.log("进来了？？??", this.endTime, this.vGoPage);
    //     if (this.endTime > 0) {
    //       this.daojishi();
    //     }
    //   },
    //   immediate: true,
    // },
  },
  methods: {
    daojishi() {
      var interval = setInterval(() => {
        this.endTime -= 1;
        console.log('剩余时间？？', this.endTime, this.vGoPage)
        // if (this.endTime == -1) {
        //   this.endTime = 0;
        //   clearInterval(interval);
        //   //跳转页面
        //   this.$router.push({ path: this.vGoPage });
        // }
      }, 1000);
    },
  },
  created() {},
  mounted() {
    this.endTime = commonGetJumpTimes();
    console.log('倒计时组件',  this.endTime, this.vGoPage);
    if (this.endTime > 0) {
      // this.daojishi();
    }
    
  },
};
</script>
<style lang='scss' scoped>
.count-down {
  position: absolute;
  left: 50px;
  .time {
  }
}
</style>